;(function($){
    //head的下拉菜单
    //prevAll()查找当前元素之前所有的同辈元素
    $(".head_menu li").mouseenter(function(){
        $(".head_menu li:eq("+$(this).prevAll().length+") div:eq(1)").show();
    })
    $(".head_menu li").mouseleave(function(){
        $(".head_menu li:eq("+$(this).prevAll().length+") div:eq(1)").hide();
    })

    //搜索框
    $("#search_p span").click(function(){
        $(".search_frame").attr("placeholder", "请输入"+this.innerHTML+"关键词");
    })
    $(".search_frame").focus(()=>{
        $(".search_frame").css("border","1px solid #e60000");
    })
    $(".search_frame").blur(()=>{
        $(".search_frame").css("border","1px solid #e6e6e6");
    })

    //侧边小图标的位置
    for(var i = 1;i<=12;i++){
        $(".i"+i).css({
            "background-position-y" : -53*(i-1)+"px"
        })
    }
    for(var i = 7;i<=10;i++){
        $(".i"+i).css({
            "background-position-y" : -54*(i-1)+"px"
        })
    }
    
      //侧边菜单和鼠标一上去时的位置变化
    $(".li").mouseenter(function(){
        $(this).children(".txt").show().not(this).children(".txt").hide();
        var nodei=$(this).children(".a").children("i")
        var he =nodei.css("background-position-y");
        nodei.css("background-position-y",Number.parseInt(he)-28+"px");
    })
    $(".li").mouseleave(function(){
        $(this).children(".txt").hide();
        var nodei=$(this).children(".a").children("i")
        var he =nodei.css("background-position-y");
        nodei.css("background-position-y",Number.parseInt(he)+28+"px");
    })
    //轮播图下面的点击滚动图
    $(".scroll_show").mouseenter(function(){
        $(this).children("div").show();
    })
    $(".scroll_show").mouseleave(function(){
        $(this).children("div").hide();
    })
    $('.scroll_show').on('click', '.show_btnr', function(ev) {
        var ulLeft = $(".scroll_show ul").css("left");
        ulLeft = Number.parseInt(ulLeft);
       if( ulLeft <= -($(".scroll_show li").length-3)*240){
            $(".scroll_show ul").css('left', 0);
       }else{
        $(".scroll_show ul").css('left', ulLeft-240+"px");
       }
        ev.stopPropagation()
    })

    $('.scroll_show').on('click', '.show_btnl', function(ev) {
         var ulLeft = $(".scroll_show ul").css("left");
        ulLeft = Number.parseInt(ulLeft);
        console.log(ulLeft)
       if(ulLeft>=0){
            $(".scroll_show ul").css('left', -($(".scroll_show li").length-3)*240+"px");
       }else{
        $(".scroll_show ul").css('left', ulLeft+240+"px");
       }
        ev.stopPropagation();
    })
    //轮播图下面的点击滚动图end
  
   //吸顶
   $(window).scroll(()=>{
    var scrollTop = $(window).scrollTop();
    scrollTop > 200 ? $(".float_logo").css("display","block") : $(".float_logo").css("display","none");
   })

})(jQuery)

//侧边选项卡
function Tab(btns,shows){
    this.btnList = Array.from(btns);
    this.showList = Array.from(shows);
    this.index = 0;
    this.bindEvent();
}
Tab.prototype.bindEvent = function(){
    // console.log(this); // 指向实例对象;
    this.btnList.forEach((btn,index) => {
          // 当使用bind的时候 我们会给每一个元素添加一个新的事件处理函数;
          btn.addEventListener("mouseenter",this.changeIndex.bind(this,index));
          btn.addEventListener("mouseenter",this.changeShow.bind(this));
    })
}
Tab.prototype.changeIndex = function(index,evt){
    var e = evt || event;
    // 所有的原型方法中的this都应该指向 实例对象;
    this.index = index;
}
Tab.prototype.changeShow = function(){
    for(var i = 0 , ele;ele =  this.showList[i];i++ ){
        if(i == this.index){
                this.btnList[i].style.borderBottom = "1px solid #c20006";
              ele.style.display = "block";
              continue;
        }else{
            ele.style.display = "none"
            this.btnList[i].style.borderBottom = "none";
        }
  }
}
var btns = $(".tab-tit li");
var contents = $(".tab-show div");
var tab = new Tab(btns,contents);

//楼梯
;!function($){
    function Stairs(selector,options){
        this.init.apply(this,arguments);
    }
    $.extend(Stairs.prototype,{
        init : function(selector,options){
            this.ele = null;
            this.options=options;
            if(typeof selector !== "string" ||(this.ele =$(selector)).length === 0 || !(options instanceof Array) || options.length === 0){
                console.warn("请输入正确的选择内容")
            }
            this.floor_timer =null;
            this.bindEvent();
        },
        bindEvent : function(){
            this.ele.on("click",this.changeFloor.bind(this));
            $(window).on("scroll",this.findFloor.bind(this));
        },
        changeFloor : function(evt){
            var target = evt.target;
            var index = $(target).parent().index();
            $(target).parent().siblings().children().removeClass("active");
            $(target).addClass("active");
            $("html,body")
            .stop()
            .animate({
                scrollTop : this.options[index]
            })
        },
        findFloor : function(){
            clearTimeout(this.floor_timer);
            if($("html,body").scrollTop()>500){
                $(".floor_box").css("display","block");
            }else{
                $(".floor_box").css("display","none");
            }
            this.floor_timer = setTimeout(function(){
                var st = $("html,body").scrollTop();
                this.index = null ;
                this.options.some((item,index) =>{
                    if(st >= item && st<item + 400){
                        this.index = index;
                        return true;
                    }
                })
                if(st>this.options[this.options.length-1]){
                    this.index = this.options.length-1;
                }
                
                this.ele.eq(this.index).children().addClass("active").parent().siblings().children().removeClass("active");
            }.bind(this),80)
        }
    })
    window.Stairs = Stairs;
}(jQuery);
new Stairs(".floor_ul li",[700,1100,1500,1900,2300,2700,3100,3500,3900,4300,4700,5100,5500,5900,6300])
